<div class="fuf-title-box bts-ats">
	<div class="fuf-title-ttl">{$title}</div>
	<a href="addUser.php"><div class="btn fuf-title-add"><i class="fa fa-plus-circle"></i>&nbsp;Tambah {$title}</div></a>
	<div class="sambungfloat"></div>
</div>
<br/>
<div class="tbl-ttl fuf-shadow">
	<div class="kiri fuf-tbl-20"><i class="fa fa-users"></i>&nbsp;Username</div>
	<div class="kiri fuf-tbl-25"><i class="fa fa-pencil"></i>&nbsp;Nama</div>
	<div class="kiri fuf-tbl-25"><i class="fa fa-envelope"></i>&nbsp;Email</div>
	<div class="kiri fuf-tbl-10 fuf-center"><i class="fa fa-graduation-cap"></i></div>
	<div class="kiri fuf-tbl-10 fuf-center"><i class="fa fa-inbox"></i></div>
	<div class="kiri fuf-tbl-10 fuf-center"><i class="fa fa-wrench"></i></div>
	<div class="sambungfloat"></div>
</div>
{foreach from=$user item=s}
<div class=" bg-white tbl-td4 fuf-shadow">
	<div class="kiri fuf-tbl-20">{$s.username}</div>
	<div class="kiri fuf-tbl-25">{$s.nama_lengkap}</div>
	<div class="kiri fuf-tbl-25">{$s.email}</div>
	<div class="kiri fuf-tbl-10 fuf-center">{$s.access}</div>
	<div class="kiri fuf-tbl-10 fuf-center">0</div>
	<div class="kiri fuf-tbl-5 fuf-center"><a href="#edit" data-toggle="modal" data-id="{$s.id_user}" class="edit"> <i class="fa fa-edit"></i></div>
	<div class="kiri fuf-tbl-5 fuf-center"><a href="user.php?action=delete&id={$s.id_user}"><i class="fa fa-trash-o"></i></a></div>
	<div class="sambungfloat"></div>
</div>
{/foreach}
<div class="modal fade bs-example-modal-sm" id="edit" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h3><i class="fa fa-edit"></i> Edit {$title} : </h3>
			</div>
			<div class="modal-body">
				<form enctype="multipart/form-data" name="editUser" action="user.php?action=edit" method="POST">
					<div class="col-md-12 paddingnone">
						<div class="paddingnone">
							<div class="col-md-6 pd-rl">
								<input type="file" class="filestyle" data-icon="false" name="filedata" id="fileToUpload">
					    		<img class="img-prev profil" src="template/images/avatar.png" id="preview" alt="preview image" />
					    		<h4>Hak Akses</h4>
					    		<div class="btn-group" data-toggle="buttons">
									<label class="btn btn-primary active">
										<input type="radio" name="access" id="personal" value="personal" autocomplete="off" checked><i class="fa fa-eye"></i> Personal
									</label>
									<label class="btn btn-primary">
										<input type="radio" name="access" id="editor" value="editor" autocomplete="off"><i class="fa fa-pencil-square"></i> Editor
									</label>
									<label class="btn btn-primary">
										<input type="radio" name="access" id="admin" value="admin" autocomplete="off"><i class="fa fa-desktop"></i> Admin
									</label>
								</div>
							</div>
							<div class="col-md-6 pd-rl">
								<input type="hidden" name="iduser" class="iduser">
								<input type="text" class="fuf-input form-control username" name="username" placeholder="Username" />
								<h4>Nama Lengkap</h4>
								<input type="text" class="fuf-input form-control nama-lengkap" name="nama_lengkap" placeholder="Nama Lengkap"  />
								<h4>Email</h4>
								<input type="email" class="fuf-input form-control email" name="email" placeholder="Email" />
								<h4>Password</h4>
								<input type="password" class="fuf-input form-control" name="password" placeholder="Password"  />
								<h4>Confirm Password</h4>
								<input type="password" class="fuf-input form-control" name="confirmPassword" placeholder="Confirm Password"  />
								<h4>Jenis Kelamin</h4>
								<div class="btn-group" data-toggle="buttons">
									<label class="btn btn-primary active">
										<input type="radio" name="gender" value="L" id="pria" autocomplete="off" checked><i class="fa fa-male"></i> Pria
									</label>
									<label class="btn btn-primary">
										<input type="radio" name="gender" value="P" id="wanita" autocomplete="off"> <i class="fa fa-female"></i> Wanita
									</label>
								</div>
							</div>
							<div class="bts-ats pd-rl">
								<button type="submit" class="btn btn-primary btn-lg bts-ats" style="width:100%;">Save</button>
							</div>
							<div class="sambungfloat"></div>
						</div>
					</div>
				</form>
				<div class="sambungfloat"></div>
			</div>
		</div>
	</div>
</div>
{literal}
<script type="text/javascript">
	$(document).ready(function() {
		$('.edit').click(function(event) {
			var id = $(this).data("id");
			$.ajax({
				url: 'user.php',
				type: 'GET',
				dataType: 'JSON',
				data: {action: 'getajax', id_user:id}
			})
			.done(function(msg) {
				$('.username').val(msg.username);
				$('.nama-lengkap').val(msg.nama_lengkap);
				$('.email').val(msg.email);
				$('.iduser').val(msg.id_user);
				$('.profil').attr({src: msg.foto_profil});
			})
			.fail(function() {
				alert("");
			})
			.always(function() {
				console.log("complete");
			});
		});
	});
	$(document).ready(function(){
		$('.logo').tooltip();
	});

	function readURL(input) {

		    if (input.files && input.files[0]) {
		        var reader = new FileReader();

		        reader.onload = function (e) {
		            $('#preview').attr('src', e.target.result);
		        }

		        reader.readAsDataURL(input.files[0]);
		    }
		}

		$("#fileToUpload").change(function(){
		    readURL(this);
		});
</script>
{/literal}
